package asm;

import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;

/**
 * Created by Shirly on 2016/10/8.
 */
public class dwada {

    public static void main(String[] args) {
        //testParse();

        dasd("12321312", "");
    }

    private static void dasd(String s, String s2) {
        SpelExpressionParser parser =  new SpelExpressionParser();
        StandardEvaluationContext context = new StandardEvaluationContext();
        context.setVariable("s", s);
        context.getRootObject().getValue();
        Object obj =  parser.parseExpression("#s").getValue(context);
        System.out.println(obj);
        SpelExpressionParser parser2 =  new SpelExpressionParser();
        Student stu = parser2.parseExpression("new asm.Student(1, 'xiaoming')").getValue(Student.class);
        System.out.println(stu.getName()+ "---" + stu.getId());
        context.setVariable("stu", stu);
        String name = parser2.parseExpression("#stu.getName()").getValue(context,String.class);
        System.out.println(name);
    }


}

class Student {
    private int id;
    private String name;

    public Student() {

    }

    public Student(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
